home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / misc / avmNfax1_33.lha / AVMSuite / rexx / silentanswer.avm < prev    next >
Text File  |  1994-06-24  |  12KB  |  470 lines

  1. /* TITLE: avm:rexx/silentanswer.avm */
  2. /* we want results! Otherwise, we wouldn't get anything from RESULT */
  3. options results
  4.  
  5. /* Need to make sure that stdtail.avm is also included */
  6. signal on halt
  7. signal on novalue
  8. signal on syntax
  9. signal on break_c
  10.  
  11. /* needed for some of the functions we use */
  12. call addlib("rexxsupport.library", 0, -30, 0)
  13.  
  14. /* a higher than normal priority since calls are important to us :) */
  15. call pragma('priority', 1)
  16.  
  17. /* ensure that commands are directed to the correct server */
  18. parse arg servername .
  19. address value servername
  20.  
  21.  
  22. parse arg servername faxscript datascript distinctivering 'CID$' acidname '$' acidnumber '$'
  23. call setclip(address() || 'CIDNAME', acidname)
  24. call setclip(address() || 'CIDNUMBER', acidnumber)
  25.  
  26. /* Initialize log entry */
  27.  
  28. handle = makeUniqueFile()
  29. call initLogEntry()
  30. log.type = 'Silent'
  31. mailbox = 'silent'
  32.  
  33. /* Put beep in here if you want */
  34.  
  35. readkeyagain:
  36. 'readnkeys' '1' '90'
  37. action = rc
  38. if action = 0 then value = result
  39. select
  40.   when action = 0 then signal possiblechoice
  41.   when action = 4 then signal stdfax
  42.   when action = 5 then signal stddata
  43.   when action = 8 then nop
  44.   when action = 10 then nop
  45.   when action = 12 then signal stdabort
  46.   when action = 14 then signal stderror
  47.   when action = 16 then signal stderror
  48.   otherwise signal arexxerror
  49. end
  50.  
  51. /* Put another beep in here if you want */
  52.  
  53. finished:
  54. /* Save log entry */
  55.  
  56. log.comment = 'Nothing done with Silent Answer'
  57. call saveLogEntry(mailbox, handle)
  58. exit
  59.  
  60. possiblechoice:
  61. select
  62.   when value = '2' then signal stdfax
  63.   when value = '1' then signal dorecord
  64.   when value = '5' then signal stddata
  65.   when value = '*' then signal stdabort
  66.   otherwise nop
  67. end
  68. signal finished
  69.  
  70. dorecord:
  71. call time('r')
  72.  
  73. 'recordvoice' '120' '-1' '-1' handle
  74. action = rc
  75. select
  76.   when action = 0 then nop
  77.   when action = 1 then nop
  78.   when action = 2 then nop
  79.   when action = 3 then nop
  80.   when action = 4 then signal stdfax
  81.   when action = 5 then signal stddata
  82.   when action = 8 then nop
  83.   when action = 10 then nop
  84.   when action = 12 then signal stdabort
  85.   when action = 14 then signal stderror
  86.   when action = 16 then signal stderror
  87.   otherwise signal arexxerror
  88. end
  89.  
  90. log.type = 'Voice'
  91. log.length = trunc(time('e'))
  92. log.filename = handle
  93. signal finished
  94.  
  95. /* TITLE: avm:rexx/simplestdtail.avm */
  96. /* This is the standard tail */
  97. exit
  98.  
  99. exit
  100.  
  101. mailboxDir: procedure
  102.     parse arg mailbox
  103.  
  104.     return 'avm:' || mailbox || '/'
  105.  
  106. logFile: procedure
  107.     parse arg mailbox, magiccookie
  108.  
  109.     return 'avm:' || mailbox || '/logs/' || magiccookie
  110.  
  111. voiceFile: procedure
  112.     parse arg mailbox, magiccookie
  113.  
  114.         if (verify(magiccookie, '/:', 'M') = 0) then
  115.           return 'avm:' || mailbox || '/voices/' || magiccookie
  116.         else
  117.           return magiccookie
  118.  
  119. makeUniqueFile: procedure
  120.     if arg() ~= 0 then do
  121.         rc = "makeUniqueFile: bad args"
  122.         signal error
  123.     end
  124.     return address() || '.' || date('i') || '.' || time('s') || '.' || random(1, 999, time('s'))
  125.  
  126. convertToDate: procedure
  127.     if arg() ~= 1 then do
  128.         rc = "convertToDate: bad args"
  129.         signal error
  130.     end
  131.     parse arg timeInC
  132.  
  133.     actualTime = (timeInC - (2922)*86400) // (86400)
  134.     actualDate = (timeInC - actualTime - 2922*86400) % 86400
  135.  
  136.     return actualDate /* returning it in 'internal' format */
  137.  
  138. convertToTime: procedure
  139.     if arg() ~= 1 then do
  140.         rc = "convertToTime: bad args"
  141.         signal error
  142.     end
  143.     parse arg timeInC
  144.     
  145.     actualTime = (timeInC - (2922)*86400) // (86400)
  146.  
  147.     return actualTime
  148.  
  149. cTime: procedure
  150.     /* 2922 = 8*365 + 2 */
  151.     /* 86400 = 24*60*60 */
  152.     return (date('i')+2922)*86400 + time('s')
  153.  
  154. /* this returns a handle that you must use after initializing log. */
  155. initLogEntry: procedure expose log.
  156.     if arg() ~= 0 then do
  157.         rc = "initLogEntry: bad args"
  158.         signal error
  159.     end
  160.     
  161.     drop log.
  162.         log. = ''
  163.  
  164.         acidname = getclip(address() || 'CIDNAME')
  165.         acidnumber = getclip(address() || 'CIDNUMBER')
  166.  
  167.     /* 2922 = 8*365 + 2 */
  168.     /* 86400 = 24*60*60 */
  169.     log.time = (date('i')+2922)*86400 + time('s')
  170.     log.cidname = acidname
  171.     log.cidnumber = acidnumber
  172.  
  173.     return
  174.  
  175. loadLogEntry: procedure expose log.
  176.     if arg() ~= 2 then do
  177.         rc = "loadLogEntry: bad args"
  178.         signal error
  179.     end
  180.     parse arg mailbox, handle
  181.  
  182.         drop log.
  183.         log. = ''
  184.  
  185.     if ~exists(mailboxDir(mailbox)) then do
  186.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  187.         return
  188.     end
  189.  
  190.     opened = open(handle, logFile(mailbox, handle), 'r')
  191.         if opened then do
  192.         call showDebugger('Loading entry' logFile(mailbox, handle))
  193.         do while ~eof(handle)
  194.             line = readln(handle)
  195.             parse upper var line variable '=' value
  196.             log.variable = value
  197.         end
  198.         call close(handle)
  199.     end; else call showDebugger('Could not load' logFile(mailbox, handle))
  200.     return
  201.  
  202. /* pass a handle here */
  203. saveLogEntry: procedure expose log.
  204.     if arg() ~= 2 then do
  205.         rc = "saveLogEntry: bad args"
  206.         signal error
  207.     end
  208.     parse arg mailbox, handle
  209.  
  210.     if ~exists(mailboxDir(mailbox)) then do
  211.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  212.         return
  213.     end
  214.  
  215.     opened = open(handle, logFile(mailbox, handle), 'w')
  216.  
  217.     if opened then do
  218.         call showDebugger('Saving entry' logFile(mailbox, handle))
  219.         call writeln(handle, 'TYPE=' || log.type)
  220.         call writeln(handle, 'TIME=' || log.time)
  221.         call writeln(handle, 'LENGTH=' || log.length)
  222.  
  223.         call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
  224.  
  225.         call writeln(handle, 'CIDNAME=' || log.cidname)
  226.         call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
  227.  
  228.         call writeln(handle, 'COMMENT=' || log.comment)
  229.  
  230.         call writeln(handle, 'FILENAME=' || log.filename)
  231.         call writeln(handle, 'ALTFILENAME=' || log.altfilename)
  232.  
  233.         call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
  234.         call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
  235.         call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
  236.  
  237.         call writeln(handle, 'RETURNRETRY=' || log.returnretry)
  238.         call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
  239.  
  240.         call close(handle)
  241.         address rexx 'broadcast' 'addtomailbox' mailbox handle
  242.     end; else call showDebugger('Could not save' logFile(mailbox, handle))
  243.  
  244.     return
  245.  
  246. /* pass a handle here */
  247. updateLogEntry: procedure expose log.
  248.     if arg() ~= 2 then do
  249.         rc = "updateLogEntry: bad args"
  250.         signal error
  251.     end
  252.     parse arg mailbox, handle
  253.  
  254.     if ~exists(mailboxDir(mailbox)) then do
  255.         call showDebugger('Dir=' || mailboxDir(mailbox) 'does not exist')
  256.         return
  257.     end
  258.  
  259.     if ~exists(logFile(mailbox, handle)) then do
  260.         call showDebugger('Unable to update non-existent' logFile(mailbox, handle))
  261.         return
  262.     end
  263.     opened = open(handle, logFile(mailbox, handle), 'w')
  264.  
  265.     if opened then do
  266.         call showDebugger('Updating entry' logFile(mailbox, handle))
  267.         call writeln(handle, 'TYPE=' || log.type)
  268.         call writeln(handle, 'TIME=' || log.time)
  269.         call writeln(handle, 'LENGTH=' || log.length)
  270.  
  271.         call writeln(handle, 'ORIGMAILBOX=' || log.origmailbox)
  272.  
  273.         call writeln(handle, 'CIDNAME=' || log.cidname)
  274.         call writeln(handle, 'CIDNUMBER=' || log.cidnumber)
  275.  
  276.         call writeln(handle, 'COMMENT=' || log.comment)
  277.  
  278.         call writeln(handle, 'FILENAME=' || log.filename)
  279.         call writeln(handle, 'ALTFILENAME=' || log.altfilename)
  280.  
  281.         call writeln(handle, 'RETURNNUMBER=' || log.returnnumber)
  282.         call writeln(handle, 'RETURNSENDFUNC=' || log.returnsendfunc)
  283.         call writeln(handle, 'RETURNSTATUS=' || log.returnstatus)
  284.  
  285.         call writeln(handle, 'RETURNRETRY=' || log.returnretry)
  286.         call writeln(handle, 'RETURNINTERVAL=' || log.returninterval)
  287.  
  288.         call close(handle)
  289.         address rexx 'broadcast' 'refreshmailboxentry' mailbox handle
  290.     end; else call showDebugger('Could not update' logFile(mailbox, handle))
  291.  
  292.     return
  293.  
  294.  
  295.  
  296. showDebugger: procedure
  297.     if arg() ~= 1 then do
  298.         say "showDebugger: ERROR"
  299.         exit 20
  300.     end
  301.  
  302.     parse arg debuggerInfo
  303.     
  304.     firstLine = sourceline(1)
  305.     parse var firstLine '/*' 'TITLE:' title '*/'
  306.     if showlist('p', 'AVMLOGGER') then
  307.         address 'AVMLOGGER' 'add' title ':' debuggerInfo
  308.     else
  309.         say title ':' debuggerInfo
  310.  
  311.     return 
  312.  
  313. /*-----------------------------------------------------------------------*/
  314. /*                         signal processing                             */
  315.  
  316. arexxerror:
  317. error:
  318.     call showDebugger("Error" rc "at line" sigl)
  319.     exit 20
  320.  
  321. break_c:
  322. halt:
  323.     call showDebugger("Halt/Break_C at line" sigl)
  324.     exit 20
  325.  
  326. novalue:
  327.     call showDebugger("No value at line" sigl)
  328.     exit 20
  329.  
  330. syntax:
  331.     call showDebugger("Syntax error" rc "at line" sigl)
  332.     exit 20
  333.  
  334. exit
  335.  
  336. /* this requires logfunctions.avm */
  337.  
  338. loadMailbox: procedure expose mailbox.
  339.     if arg() ~= 1 then do
  340.         rc = "loadMailbox: bad args"
  341.         signal error
  342.     end
  343.  
  344.         mailbox. = ''
  345.     parse arg mailbox
  346.  
  347.     handle = 'mailboxconfig'
  348.     opened = open(handle, mailboxDir(mailbox) || 'mailbox.cfg', 'r')
  349.     if opened then do
  350.         do while ~eof(handle)
  351.             line = readln(handle)
  352.             parse upper var line variable '=' value
  353.             mailbox.variable = value
  354.         end
  355.         call close(handle)
  356.     end
  357.     return
  358.  
  359. /* pass a handle here */
  360. saveMailbox: procedure expose mailbox.
  361.     if arg() ~= 1 then do
  362.         rc = "saveMailbox: bad args"
  363.         signal error
  364.     end
  365.     parse arg mailbox
  366.  
  367.     handle = 'mailboxconfig'
  368.     opened = open(handle, mailboxDir(mailbox) || 'mailbox.cfg', 'w')
  369.  
  370.     if opened then do
  371.         call writeln(handle, 'PASSWORD=' || mailbox.password)
  372.  
  373.         call writeln(handle, 'AUTOFAXFORWARDB=' || mailbox.autofaxforwardb)
  374.         call writeln(handle, 'AUTOFAXFORWARD=' || mailbox.autofaxforward)
  375.         call writeln(handle, 'AUTOFAXFORWARDSCRIPT=' || mailbox.autofaxforwardscript)
  376.  
  377.         call writeln(handle, 'AUTOFORWARDB=' || mailbox.autoforwardb)
  378.         call writeln(handle, 'AUTOFORWARDONDEMAND=' || mailbox.autoforwardondemand)
  379.         call writeln(handle, 'AUTOFORWARD=' || mailbox.autoforward)
  380.         call writeln(handle, 'AUTOFORWARDSCRIPT=' || mailbox.autoforwardscript)
  381.  
  382.         call writeln(handle, 'AUTOPAGEB=' || mailbox.autopageb)
  383.         call writeln(handle, 'AUTOPAGEONDEMAND=' || mailbox.autopageondemand)
  384.         call writeln(handle, 'AUTOPAGE=' || mailbox.autopage)
  385.         call writeln(handle, 'AUTOPAGESCRIPT=' || mailbox.autopagescript)
  386.  
  387.         call writeln(handle, 'AUTOALERTB=' || mailbox.autoalertb)
  388.         call writeln(handle, 'AUTOALERTONDEMAND=' || mailbox.autoalertondemand)
  389.         call writeln(handle, 'AUTOALERTSCRIPT=' || mailbox.autoalertscript)
  390.  
  391.         call close(handle)
  392.     end
  393.  
  394.     return
  395.  
  396. stdabort:
  397. exit
  398.  
  399. stdbusy:
  400. exit
  401.  
  402. stderror:
  403. exit
  404.  
  405. stdtimedout:
  406. exit
  407.  
  408. stdfaxinstruct:
  409. 'playvoice' 'avm:voices/FaxStarting'
  410. action = rc
  411. select
  412.   when action = 0 then nop
  413.   when action = 1 then do; call checkifabort; end
  414.   when action = 4 then nop
  415.   when action = 5 then nop
  416.   when action = 8 then signal stdbusy
  417.   when action = 12 then signal stdabort
  418.   when action = 14 then nop
  419.   when action = 16 then nop
  420.   otherwise signal arexxerror
  421. end
  422.  
  423. stdfax:
  424. faxscript = getclip(address() || 'FAXSCRIPT')
  425. if faxscript = '' then faxscript = 'handlefax'
  426. if symbol('mailbox') = 'VAR' then address rexx faxscript address() mailbox
  427. else address rexx faxscript address() 'anonymous'
  428. exit
  429.  
  430. stddatainstruct:
  431. 'playvoice' 'avm:voices/DataStarting'
  432. action = rc
  433. select
  434.   when action = 0 then nop
  435.   when action = 1 then do; call checkifabort; end
  436.   when action = 4 then nop
  437.   when action = 5 then nop
  438.   when action = 8 then signal stdbusy
  439.   when action = 12 then signal stdabort
  440.   when action = 14 then nop
  441.   when action = 16 then nop
  442.   otherwise signal arexxerror
  443. end
  444.  
  445. stddata:
  446. datascript = getclip(address() || 'DATASCRIPT')
  447. if datascript = '' then datascript = 'handledata'
  448. if symbol('mailbox') = 'VAR' then address rexx datascript address() mailbox
  449. else address rexx datascript address()
  450. exit
  451.  
  452. checkifabort:
  453. 'readnkeys' '1' '3'
  454. action = rc
  455. if action = 0 then value = result
  456. select
  457.   when action = 0 then do; if value = '*' then signal stdabort; end
  458.   when action = 4 then nop
  459.   when action = 5 then nop
  460.   when action = 8 then signal stdbusy
  461.   when action = 10 then nop
  462.   when action = 12 then signal stdabort
  463.   when action = 14 then signal stderror
  464.   when action = 16 then signal stderror
  465.   otherwise signal arexxerror
  466. end
  467. return
  468.  
  469.  
  470.